<template>
	<view class="popup-overlay" v-if="show" @click.stop="handleOverlayClick">
		<view class="popup-content" @click.stop>
			<view class="popup-header">
				<text class="popup-title">填写合同信息</text>
				<text class="popup-close" @click="close">×</text>
			</view>
			
			<view class="contract-form">
				<view class="form-item">
					<text class="form-label">合同编号</text>
					<input class="form-input" type="text" value="PK-2025-001" disabled />
					<text class="form-hint">系统自动生成</text>
				</view>
				
				<view class="form-item">
					<text class="form-label">确认合同</text>
					<view class="contract-confirm">
						<checkbox :checked="contractConfirmed" @click="toggleConfirm" />
						<text class="contract-text">我已阅读并同意《停车位租赁合同》</text>
					</view>
				</view>
			</view>
			
			<view class="popup-footer">
				<button class="cancel-btn" @click="close">取消</button>
				<button class="confirm-btn" @click="submit" :disabled="!contractConfirmed">提交</button>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	name: 'ContractPopup',
	props: {
		show: {
			type: Boolean,
			default: false
		}
	},
	data() {
		return {
			contractConfirmed: false
		}
	},
	methods: {
		close() {
			this.$emit('close')
		},
		submit() {
			if (!this.contractConfirmed) {
				uni.showToast({
					title: '请先确认合同',
					icon: 'none'
				})
				return
			}
			this.$emit('submit')
		},
		toggleConfirm() {
			this.contractConfirmed = !this.contractConfirmed
		},
		handleOverlayClick() {
			// 点击遮罩层不关闭弹窗
		}
	}
}
</script>

<style>
.popup-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 999;
}

.popup-content {
	width: 650rpx;
	background-color: #fff;
	border-radius: 12rpx;
	padding: 30rpx;
}

.popup-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 30rpx;
	padding-bottom: 20rpx;
	border-bottom: 1rpx solid #eee;
}

.popup-title {
	font-size: 32rpx;
	font-weight: bold;
	color: #333;
}

.popup-close {
	font-size: 40rpx;
	color: #999;
}

.contract-form {
	margin-bottom: 30rpx;
}

.form-item {
	margin-bottom: 20rpx;
}

.form-label {
	font-size: 28rpx;
	color: #333;
	margin-bottom: 15rpx;
	display: block;
}

.form-input {
	width: 100%;
	height: 80rpx;
	background-color: #f5f5f5;
	border-radius: 8rpx;
	padding: 0 20rpx;
	font-size: 28rpx;
	box-sizing: border-box;
}

.form-hint {
	font-size: 24rpx;
	color: #999;
	margin-top: 10rpx;
	display: block;
}

.contract-confirm {
	display: flex;
	align-items: center;
}

.contract-text {
	font-size: 28rpx;
	color: #333;
	margin-left: 10rpx;
}

.popup-footer {
	display: flex;
	justify-content: flex-end;
}

.cancel-btn {
	background-color: #f5f5f5;
	color: #666;
	font-size: 28rpx;
	padding: 15rpx 30rpx;
	border-radius: 8rpx;
	margin-right: 20rpx;
}

.confirm-btn {
	background-color: #1890ff;
	color: #fff;
	font-size: 28rpx;
	padding: 15rpx 30rpx;
	border-radius: 8rpx;
}

.confirm-btn[disabled] {
	background-color: #ccc;
	color: #fff;
}
</style> 